﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using HCFramework.API.LINQ;

namespace HCFramework.Control.News
{
    public partial class UsrNewsDetail : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                LoadNews();
                if (C.UserController.IsAdmin()) linkButtonEdit.Visible = true;
            }
        }

        private void LoadNews()
        {
            New n = C.NewsController.GetByID(M.UrlQuery.newsID.Value);
            litTitle.Text = n.Title;
            litContent.Text = n.Content;
            litDate.Text = n.DateCreated.ToString();
            this.Page.Title = n.Title;
        }

        protected void linkButtonEdit_Click(object sender, EventArgs e)
        {
            panelDetail.Visible = false;
            panelEdit.Visible = true;
        }
    }
}